﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace ControlLibrary.Extensions;

public class DateTimeRangeConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        if (values.Length < 2 || values[0] is not DateTime start || values[1] is not DateTime end) return values;
        if (parameter is not string parm)
        {
            parm = "~";
        }

        if (start > end)
        {
            (end, start) = (start, end);
        }

        return $"{start:yyyy-MM-dd HH:mm} {parm} {end:yyyy-MM-dd HH:mm}";
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}